* REPLICATION CODE FOR INSTRUMENTAL VARIABLE FIXED EFFECTS 2SLS REGRESSION ESTIMATES
* APPENDIX TO: "DOES THE CROWD PROMISE TO FUND MORE INNOVATION?"
* July 15, 2016

import delimited "yearly_fe_final.csv", clear
*import delimited "/Users/OlavSorenson/LaCie/Dropbox/cfgeo/Data/yearly_fe_final.csv", clear

gen log_count_vc = log(vc_count+1)
gen log_amount_vc = log(vc_amount+1)
gen log_patents = log(num_patents+1)
gen log_citations = log(num_citations+1)
gen log_amount_ks = log(amount+1)
gen log_campaigns_ks =log(num_campaigns+1)
gen log_successful_ks = log(num_successful+1)
gen log_instrument_ks = log(instrument_successful+1)
gen log_instrument_all = log(instrument_all+1)
gen log_successful_ks_100 =log(successful_100+1)

* set up the panel structure of the data by fips code and year
* ssc install xtivreg2

*-----------------------------
* TABLE S6
*-----------------------------

set more off
* panel IV
xtset fips year
xi: xtivreg2 log_count_vc log_patents  log_citations i.year (log_successful_ks = log_instrument_ks), fe /* second stage, just VC count */
xtivreg2 log_count_vc log_patents  log_citations (log_successful_ks = log_instrument_ks), fe first /* first stage */

* panel IV with year trend
xi: xtreg log_successful_ks log_instrument_ks log_patents log_citations i.year, fe  /* second stage VC count with year interaction */
predict manual_main
gen manual_int=(year-2009)*manual_main
xi: bootstrap, reps(1000): xtreg log_count_vc manual_main manual_int log_patents log_citations i.year, fe


* All campaigns
* panel IV
xtset fips year
xi: xtivreg2 log_count_vc log_patents  log_citations i.year (log_campaigns_ks = log_instrument_all), fe /* second stage, just VC count */
xtivreg2 log_count_vc log_patents  log_citations (log_campaigns_ks = log_instrument_all), fe first /* first stage */

* panel IV with year trend
xi: xtreg log_campaigns_ks log_instrument_all log_patents log_citations i.year, fe  /* second stage VC count with year interaction */
predict manual_main
gen manual_int=(year-2009)*manual_main
xi: bootstrap, reps(1000): xtreg log_count_vc manual_main manual_int log_patents log_citations i.year, fe

*----------------------------------------------------------
* ROBUSTNESS CHECKs 
*----------------------------------------------------------

* KICKSTARTER TECHNOLOGY CAMPAIGNS ONLY 
import delimited "yearly_fe_tech.csv", clear

gen log_count_vc = log(vc_count+1)
gen log_amount_vc = log(vc_amount+1)
gen log_patents = log(num_patents+1)
gen log_citations = log(num_citations+1)
gen log_amount_ks = log(amount+1)
gen log_campaigns_ks =log(num_campaigns+1)
gen log_successful_ks = log(num_successful+1)
gen log_instrument_ks = log(instrument_successful+1)
gen log_successful_ks_100 =log(successful_100+1)

* panel IV
xtset fips year
xi: xtivreg2 log_count_vc log_patents  log_citations i.year (log_successful_ks = log_instrument_ks), fe /* second stage, just VC count */
xtivreg2 log_count_vc log_patents  log_citations (log_successful_ks = log_instrument_ks), fe first /* first stage */

* panel IV with year trend
xtset fips year
xi: xtreg log_successful_ks log_instrument_ks log_patents log_citations i.year, fe  /* second stage VC count with year interaction */
predict manual_main
gen manual_int=(year-2009)*manual_main
xi: bootstrap, reps(1000): xtreg log_count_vc manual_main manual_int log_patents log_citations i.year, fe

